<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <div th:replace="common/fragment::leftmenu"></div>
    <!--End 左侧导航-->

    <!--头部信息-->
    <div th:replace="common/fragment::header"></div>
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content">

      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form action="" class="pull-right search-bar" method="get" role="form">
                  <div class="input-group">
                    <div class="input-group-btn">
                      <label  for="status-select">选择框</label>

                      <select class="form-control" id="status-select" name="example-select" size="1">
                        <option value="-999"> </option>
                        <option th:each="val:${purstatusval}" th:value="${val}" th:text="${purstatusname[val]}">选项 #1</option>

                      </select>
                    </div>

                    <span class="input-group-btn">
                                              <button class="btn btn-primary" id="keyword-find-btn"
                                                      onclick="keywordsearch()"
                                                      type="button">搜索</button>
                                            </span>

                  </div>
                </form>

                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" id="addpurchase-btn" href="/purchase/addpurchase.do?status=">
                    <i class="mdi mdi-plus"></i>
                    新增
                  </a>
                  <!--
                  <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                  <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                  <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                  -->
                </div>
              </div>
              <div class="card-body">
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                    <tr>
                      <th>序号</th>
                      <th hidden="hidden">id</th>
                      <th>订单号</th>
                      <th>供应商</th>
                          <th>责任人</th>
                      <th>状态</th>

                      <th>生成日期</th>
                      <th>要货日期</th>
                      <th>总金额</th>
                      <th>备注</th>
                      <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="pur:${purlist}">

                      <td th:text="${purStat.index+1}"></td>
                      <td hidden="hidden" th:text="${pur.id}"></td>

                      <td th:text="${pur.name}"></td>
                      <td th:text="${pur.supplierPO.name}">供应商</td>
                      <td th:text="${pur.userPO.username}"></td>
                      <td th:text="${purstatusname[pur.status]}"></td>
                      <td th:text="${#dates.format(pur.createTime, 'yyyy-MM-dd')}"></td>

                      <td th:text="${#dates.format(pur.need, 'yyyy-MM-dd')}"></td>
                      <td th:text="${#numbers.formatDecimal(pur.sumPurDetail,1,'COMMA',2,'POINT')}"></td>
                      <td th:text="${pur.comment}"></td>

                      <td>
                        <div class="btn-group">
                          <a class="btn btn-xs btn-default editpur"
                             data-toggle="tooltip"
                             th:href="@{${pur.id}}" title="编辑">
                            <i class="mdi mdi-pencil"></i>
                          </a>
<!--                          <a class="btn btn-xs btn-default forbidden"-->
<!--                             data-toggle="tooltip"-->

<!--                             th:href="@{${pur.id}}" title="禁用">-->
<!--                            <i class="mdi mdi-alert-outline"></i>-->
<!--                          </a>-->
                        </div>
                      </td>
                    </tr>

                    </tbody>
                  </table>
                </div>

              </div>
            </div>
          </div>

        </div>

      </div>
    </main>
    <!--End 页面主要内容-->
    <!--End 页面主要内容-->
  </div>
</div>
<div th:replace="common/fragment::tail-script"></div>
<!--<script type="text/javascript" th:inline="javascript">-->
<!--  /*<![CDATA[*/-->
<!--  var max = /*[[${maxSumOfDateInYear}]]*/ 20;-->
<!--  alert(max);-->
<!--  /*]]>*/-->
<!--</script>-->

<script type="text/javascript">


  $(document).ready(function () {
// 新建订单按钮
    $('#addpurchase-btn').click(function (e) {
      let select = $('#status-select').val()
      if(select===''){
        select=-999
      }
        window.location.href="/purchase/addpurchase.do"
      e.preventDefault();
    });
// END新建订单按钮

// 按状态搜索
/*    $('#keyword-find-btn').click(function () {
      let status = $('#status-select').val()
      window.location.href = "/purchase/purchaselist.do?status="+status
    });*/
// END 按状态搜索

// 查看订单
    $('.editpur').each(function (i,e) {
      $(this).click(function (ev) {
        let id = $(this).attr('href')
        // 发生页面跳转
        window.location.href="/purchase/editpur.do?purid="+id
        ev.preventDefault()
      });
    });
// END 查看订单

  });

</script>
</body>
</html>